package website.seamonster.ethegg.dataobject;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * Created by 罗海量
 * 2018-08-17 14:40
 */
@Entity
@Table(name = "eth_user")
@Slf4j
@Data
@DynamicInsert
@DynamicUpdate
public class EthUser {

    private long id;
    private String ethAddress;
    private String prCode;
    private Timestamp prActiveTime;
    private Timestamp prEndTime;
    private Timestamp createTime;

    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "ETH_ADDRESS")
    public String getEthAddress() {
        return ethAddress;
    }

    public void setEthAddress(String ethAddress) {
        this.ethAddress = ethAddress;
    }

    @Basic
    @Column(name = "PR_CODE")
    public String getPrCode() {
        return prCode;
    }

    public void setPrCode(String prCode) {
        this.prCode = prCode;
    }

    @Basic
    @Column(name = "PR_ACTIVE_TIME")
    public Timestamp getPrActiveTime() {
        return prActiveTime;
    }

    public void setPrActiveTime(Timestamp prActiveTime) {
        this.prActiveTime = prActiveTime;
    }

    @Basic
    @Column(name = "PR_END_TIME")
    public Timestamp getPrEndTime() {
        return prEndTime;
    }

    public void setPrEndTime(Timestamp prEndTime) {
        this.prEndTime = prEndTime;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        EthUser ethUser = (EthUser) o;

        if (id != ethUser.id) return false;
        if (ethAddress != null ? !ethAddress.equals(ethUser.ethAddress) : ethUser.ethAddress != null) return false;
        if (prCode != null ? !prCode.equals(ethUser.prCode) : ethUser.prCode != null) return false;
        if (prActiveTime != null ? !prActiveTime.equals(ethUser.prActiveTime) : ethUser.prActiveTime != null)
            return false;
        if (prEndTime != null ? !prEndTime.equals(ethUser.prEndTime) : ethUser.prEndTime != null) return false;
        if (createTime != null ? !createTime.equals(ethUser.createTime) : ethUser.createTime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (ethAddress != null ? ethAddress.hashCode() : 0);
        result = 31 * result + (prCode != null ? prCode.hashCode() : 0);
        result = 31 * result + (prActiveTime != null ? prActiveTime.hashCode() : 0);
        result = 31 * result + (prEndTime != null ? prEndTime.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        return result;
    }
}
